import { createSlice } from "@reduxjs/toolkit";

import type { RootState } from "@/store";

export interface ThemeState {
  primaryColor: string;
  themeDarkColor: string;
  themeBrightColor: string;
  systemName: string;
  isDark: boolean;
}
const initialState: ThemeState = {
  primaryColor: "#1890ff", // 默认主题颜色
  themeDarkColor: "#141414", // 黑暗主题颜色
  themeBrightColor: "#ffffff", // 明亮主题颜色
  systemName: "Merchant Dashboard",
  isDark: false,
};

export const themeSlice = createSlice({
  name: "theme",
  initialState: initialState,
  reducers: {
    setDark(state, { payload }) {
      state.isDark = payload;
    },
  },
});

export const selectPrimaryColor = (state: RootState) => state.theme.primaryColor;
export const selectDark = (state: RootState) => state.theme.isDark;
export const selectTheme = (state: RootState) => state.theme;
export const { setDark } = themeSlice.actions;
export default themeSlice.reducer;
